!function(win,doc){
	win.myCharts = {
		//配置
		config:{
			title:{
				x: "center",
				y: "top",
				textStyle: {
					color: "#aaddff",
					fontSize: 14,
				}
			},
			grid: {
				x: "12%",
				y: "10%",
				x2: "5%",
				y2: 32
			},
			axisLabel: {
				textStyle: {
					color: "#fff",
					fontSize: 10
				}
			},
			axisTick: {show: false},
			tooltip: {
				trigger: "axis",
				axisPointer: {
					lineStyle: {
						type: "dotted"
					}
				}
			},
			legend:{
				right: "5%",
				y: 20,
				// icon:'circle',
				itemWidth: 10,
				itemHeight: 10,
				itemGap: 10,
				textStyle: {
					color: "#dcfffe",
					fontSize: 10
				}
			},
			axisLine: {
				lineStyle: {
					color: "#c4e2e7"
				}
			},
			colors1: ["#1697ff", "#f87b1e","#07c0ec"],
			colors2: ["#1697ff", "#f87b1e","#62e4a9"],
			colors3: ["#33ddf8", "#2473ef"],
			colors4: ["#1b39b6", "#15a199", "#1bcee9", "#1b73ca", "#2a93fa"],
		},
		
		//初始化chart
		init:function(domId){
			var $dom = doc.getElementById(domId);
			var myChart = echarts.init($dom);
			myChart.showLoading({color:'#dcfffe',text:'',maskColor:'rgba(0, 0, 0, 0)'});	//loading
			return myChart;
		},
		
		//chart展示
		showChart:function(myChart, theOption) {
			myChart.hideLoading();
			myChart.setOption(theOption);
			
			//窗口缩放后重新调整图标尺寸
			win.addEventListener('resize', function() {
				myChart.resize()
			})
		},
		
		//柱图1 监造完成率
		option1:function(title, xAxis, values){
			var theOption = {
				title:this.config.title,
				tooltip:this.config.tooltip,
				grid:{
					x: "10%",
					y: "20%",
					x2: "6%",
					y2: "8%"
				},
				legend:{
					right: "7%",
					y: "14%",
					itemWidth: 10,
					itemHeight: 10,
					itemGap: 10,
					textStyle: {
						color: "#dcfffe",
						fontSize: 10
					}
				},
				xAxis: {
					type: 'category',
					data: xAxis,
					axisLabel:this.config.axisLabel,
					axisLine:this.config.axisLine,
					axisTick:this.config.axisTick,
				},
				yAxis: [
					{
						type: "value",
						boundaryGap: false,
						splitLine:{show: false},
						axisLabel:this.config.axisLabel,
						axisLine:this.config.axisLine,
						axisTick:this.config.axisTick,
					},
					{
						type: "value",
						boundaryGap: false,
						splitLine:{show: false},
						axisLabel:{
							textStyle:this.config.axisLabel.textStyle,
							formatter: "{value}%"
						},
						axisLine:this.config.axisLine,
						axisTick:this.config.axisTick,
						max:100,
						min:0
					}
				],
				series: [{
					name: "下达数量",
					data: values[0],
					type: 'bar',
					barWidth: "30%",
				}, {
					name: "完成数量",
					data: values[1],
					type: 'bar',
					barWidth: "30%",
				}, {
					name: "完成率",
					data: values[2],
					type: 'line',
					smooth: true,
					yAxisIndex: 1,
					showSymbol: false,
					itemStyle: {
						normal: {
							areaStyle: { 
								color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
									offset: 0,
									color: 'rgba(44, 132, 203, 0)'
								}, {
									offset: 1,
									color: 'rgba(44, 132, 203, 1.0)'
								}]),
							}
						}
					},
				}],
				color:this.config.colors1
			};
			if (title) {
				theOption.title.text = title
			}else{
				delete theOption.title
			}
			
			return theOption;
		},
		
		//图2 监造策略应用情况 饼图
		option2:function(title, legends, values){
			var theOption = {
				title:this.config.title,
				tooltip: {
					trigger: "item",
					formatter: "{b}:{c} ({d}%)",
				},
				legend: {
					data: legends,
					icon:"circle",
					y: "bottom",
					right: "5%",
					itemGap: 25,
					orient: "vertical",
					itemWidth:this.config.legend.itemWidth,
					itemHeight: this.config.legend.itemHeight,
					textStyle: this.config.legend.textStyle,
				},
				series: [{
					type: "pie",
					radius: ["40%", "65%"],
					center: ['45%', '65%'],
					itemStyle: {
						normal: {
							label: {
								show: true,
								position: "bottom",
								distance: 0.5,
								formatter: "{d}%"
							},
							labelLine: {
								show: true
							}
						}
					},
					data: values,
				}],
				color:this.config.colors2
			}
			if (title) {
				theOption.title.text = title
				theOption.title.top = "6%"
			}else{
				delete theOption.title
			}
			
			return theOption;
		},
		
		//图3 出一次性通过率
		option3:function(title, yAxis, values){
			var _this = this;
			var theOption = {
				title:this.config.title,
				tooltip:this.config.tooltip,
				grid: {
					x: "20%",
					y: "10%",
					x2: "8%",
					y2: "16%"
				},
				xAxis: {
					type: 'value',
					axisLabel:this.config.axisLabel,
					axisLine:this.config.axisLine,
					boundaryGap: false,
					splitLine:{show: false},
					min:0,
					max:100,
					axisTick:this.config.axisTick,
				},
				yAxis: [
					{
						type: "category",
						data:yAxis,
						axisLabel:this.config.axisLabel,
						axisLine:this.config.axisLine,
						axisTick:this.config.axisTick,
					}
				],
				series: [{
					data: values,
					type: 'bar',
					barWidth: "30%",
					label: {
						normal: {
							show: true,
							position: 'right',
							formatter: '{c}%',
						}
					},
					itemStyle: {
						normal: {
							show: true,
							color: function(params) {
								let num = _this.config.colors3.length;
								return _this.config.colors3[params.dataIndex % num]
							},
						},
					}
				}],
			};
			if (title) {
				theOption.title.text = title
				theOption.grid.y = "20%"
			}else{
				delete theOption.title
			}
			
			return theOption;
		},
		
		//图4 不合格情况
		option4:function(title, xAxis, values){
			var theOption = {
				title:this.config.title,
				tooltip:this.config.tooltip,
				grid: {
					x: "14.2%",
					y: "15%",
					x2: "5%",
					y2: "20%"
				},
				xAxis: {
					type: 'category',
					data: xAxis.map(function(item){
						return item.split("").map(function(v,i){
						   if (i>0&&i%2==0) return v+"\n"
							else return v
						}).join("")
					}),
					axisLabel:this.config.axisLabel,
					axisLine:this.config.axisLine,
					axisTick:this.config.axisTick,
				},
				yAxis: [
					{
						type: "value",
						name:"数量",
						boundaryGap: false,
						splitLine:{show: false},
						axisLabel:this.config.axisLabel,
						axisLine:this.config.axisLine,
						axisTick:this.config.axisTick,
					}
				],
				series: [{
					data: values,
					type: 'bar',
					barWidth: "15%",
					itemStyle: {
						normal: {
							color: function(params) { //展示负值的柱子，正数设为透明
								return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
									offset: 0,
									color: "#1594ff"
								}, {
									offset: 1,
									color: "#3fc0ff"
								}], false)
							},
						}
					}
				}],
			};
			if (title) {
				theOption.title.text = title
				theOption.grid.y = "25%"
			}else{
				delete theOption.title
			}
			
			return theOption;
		},
		
		//图5 合格率
		option5:function(title, xAxis, values){
			var theOption = {
				title:this.config.title,
				tooltip:this.config.tooltip,
				grid: {
					x: "12.5%",
					y: "15%",
					x2: "5%",
					y2: "20%"
				},
				xAxis: {
					type: 'category',
					data: xAxis,
					axisLabel:this.config.axisLabel,
					axisLine:this.config.axisLine,
					axisTick:this.config.axisTick,
				},
				yAxis: [
					{
						type: "value",
						boundaryGap: false,
						splitLine:{show: false},
						axisLine:this.config.axisLine,
						max:100,
						min:0,
						axisLabel:{
							textStyle:this.config.axisLabel.textStyle,
							formatter: "{value}%"
						},
						axisTick:this.config.axisTick,
					}
				],
				series: [{
					data: values,
					type: 'line',
					smooth: true,
					itemStyle: {
						normal: {
							areaStyle: { 
								color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
									offset: 0,
									color: 'rgba(44, 132, 203, 0)'
								}, {
									offset: 1,
									color: 'rgba(44, 132, 203, 1.0)'
								}]),
							}
						}
					},
				}],
				color:this.config.colors3
			};
			if (title) {
				theOption.title.text = title
				theOption.grid.y = "25%"
			}else{
				delete theOption.title
			}
			
			return theOption;
		},
		
		//图6 不合格供应商统计
		option6:function(title, xAxis, values){
			var theOption = {
				title:this.config.title,
				tooltip:this.config.tooltip,
				legend:{
					right: "10%",
					y: 30,
					itemWidth: 10,
					itemHeight: 10,
					itemGap: 10,
					textStyle: {
						color: "#dcfffe",
						fontSize: 10
					}
				},
				grid: {
					x: "10%",
					y: "15%",
					x2: "10%",
					y2: "20%"
				},
				xAxis: {
					type: 'category',
					data: xAxis,
					axisLabel:this.config.axisLabel,
					axisLine:this.config.axisLine,
					axisTick:this.config.axisTick,
				},
				yAxis: [
					{
						type: "value",
						boundaryGap: false,
						splitLine:{show: false},
						axisLabel:this.config.axisLabel,
						axisLine:this.config.axisLine,
						axisTick:this.config.axisTick,
					}
				],
				series: [{
					name:"标1",
					data: values[0],
					type: 'bar',
					stack: 1,
					barWidth: "15%",
				},
				{
					name:"标2",
					data: values[1],
					type: 'bar',
					stack: 1,
					barWidth: "15%",
				},
				{
					name:"标3",
					data: values[2],
					type: 'bar',
					stack: 1,
					barWidth: "15%",
				},
				{
					name:"标4",
					data: values[3],
					type: 'bar',
					stack: 1,
					barWidth: "15%",
				}],
				color:this.config.colors4
			};
			if (title) {
				theOption.title.text = title
				theOption.grid.y = "25%"
			}else{
				delete theOption.title
			}
			
			return theOption;
		},
		
		//图7 雷达图 供应商绩效评价
		option7:function(indicator, values, axisName) {
			var theOption = {
				radar: {
					center: ['40%', '60%'],
					shape: 'circle', //形状
					name: {
						textStyle: {
							color: '#ffffff',
						}
					},
					splitLine: {
						lineStyle: {
							color:this.config.colors1[0],
							width: 1,
						}
					},
					splitArea: {
						areaStyle: {
							color: ['rgba(12,40,110, 0.9)'],
							shadowColor: 'rgba(9, 127, 182, 1.0)',
							shadowBlur: 20, 
						}
					},
					indicator:indicator.map(function(item,index){
						if(index>0){
							item.axisLabel={show:false}
						}
						item.max=Math.max.apply(null,values)
						return item
					})
				},
				tooltip: {},
				series: [{
					type: 'radar',
					data: [{
						value:values,
						name: axisName,
						itemStyle: {
							normal: {
								color: '#ffffff'
							}
						}
					}]
				}]
			};
			return theOption;
		},
		
		//图8 不良行为处理
		option8:function(title, xAxis, values){
			var theOption = {
				title:this.config.title,
				tooltip:this.config.tooltip,
				grid: {
					x: "15%",
					y: "15%",
					x2: "5%",
					y2: "16%"
				},
				legend:this.config.legend,
				xAxis: {
					type: 'category',
					data: xAxis,
					axisLabel:this.config.axisLabel,
					axisLine:this.config.axisLine,
					axisTick:this.config.axisTick,
				},
				yAxis: [
					{
						type: "value",
						boundaryGap: false,
						splitLine:{show: false},
						axisLabel:this.config.axisLabel,
						axisLine:this.config.axisLine,
						axisTick:this.config.axisTick,
					}
				],
				series: [{
					name: "处罚",
					data: values[0],
					type: 'bar',
					barWidth: "15%",
				}, {
					name: "退换货",
					data: values[1],
					type: 'bar',
					barWidth: "15%",
				}],
				color:this.config.colors1
			};
			if (title) {
				theOption.title.text = title
				theOption.grid.y = "20%"
			}else{
				delete theOption.title
			}
			
			return theOption;
		}
	}
}(window,document)